// ===============================================================================
// scan: sequential scan of a large descriptor collection
// Created in September 2007 as a project for an Advanced Database Systems course
// (c) Reykjavik University, Björn Þór Jónsson, Kristleifur Daðason, Herwig Lejsek
// Contact author: Björn Þór Jónsson, Reykjavík University, bjorn@ru.is
// ===============================================================================

#ifndef INDEXMAPPER
#define INDEXMAPPER

#include <string>
#include <iostream>
                   
#include <sys/stat.h>
#include <stdio.h> 

#include <sys/types.h>
//#include <sys/mman.h>  

#include <errno.h>

#include "IndexEntry.h"
#include "FlexDescriptor.h"
#include "ClusterMapper.h"
#include "ConfigMapper.h"
                          
using namespace std;

class IndexMapper
{
public:
	IndexMapper(ConfigMapper *cnfg);
	~IndexMapper();	
 	int getNumClusters(); 
	FlexDescriptor *getCentroid(int i);
	ClusterMapper *getCluster(int i);

private:
	// Bookkeeping info
	ConfigMapper *cnfgMapper;
	unsigned int numClusters;
	int indexEntrySize;

	// File and mapping info about the index file
	FILE* indxFile;
	int fileSize;
	unsigned char *mapPtr;

	// Info about the data file, which must be opened as well
	FILE *dataFile;
};

#endif

